#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#


names = ["hei", "bai", "hong", "nv"]

# 映射，将列表的旧值映射为新的值
m_name = map(lambda x: x + "XXS", names)  # ['heiXXS', 'baiXXS', 'hongXXS', 'nvXXS']
print(list(m_name))
# 与如下的列表生成式相等
m_name = [name + "ssss" for name in names]
print(m_name)

names = ["xiongge", "wo", "ni", "hao"]
res = [name for name in names if name.endswith("ge")]
print(res)

f_name = filter(lambda x: not x.endswith("ge"), names)
print(f_name)  # <filter object at 0x000002B9433EB240>
print(list(f_name))  # ['wo', 'ni', 'hao']

x = map(lambda x: x % 2, range(10))
print(list(x))

y = filter(lambda x: x % 2, range(10))
print(list(y))
